package com.virtualCat.dao;

import com.virtualCat.entity.Cat;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface CatDao {
    /**
     * 添加猫咪信息
     * @param cat
     * @return
     */
    @Insert("insert into t_cat(cname,cimg,gname,gimg,nprice,oprice,cdesc,gdesc,detail) " +
            "values(#{cname},#{cimg},#{gname},#{gimg},#{nprice},#{oprice},#{cdesc},#{gdesc},#{detail})")
    int insert(Cat cat);

    /**
     * 获取猫咪的列表
     */
    @Select("select * from t_cat")
    List<Cat> findAll();

    /**
     * 修改猫咪信息
     * @param cat
     * @return
     */
    @Update("update t_cat set cname=#{cname},cimg=#{cimg},gname=#{gname},gimg=#{gimg},nprice=#{nprice}," +
            "oprice=#{oprice},cdesc=#{cdesc},gdesc=#{gdesc},detail=#{detail} where catid = #{catid}")
    int update(Cat cat);

    /**
     * 获取单个猫咪的信息
     * @param cat_id 猫咪序列号
     */
    @Select("select * from t_cat where catid=#{cat_id}")
    Cat findById(@Param("cat_id") int cat_id);

    /**
     * 删除猫咪信息
     * @param catId
     * @return
     */
    @Delete("delete * from t_cat where cat_id=#{catId}")
    int delete(Integer catId);

}
